//
// Created by MikeChen on 2025/3/24.
//


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define PRINT_VAR1(var) printf("%s = %d\n",#var,var)
#define PRINT_VAR2(var) printf("%s = %u\n",#var,var)

int main() {
    printf("int %d\n", sizeof(int));//4
    printf("unsigned int %d\n", sizeof(unsigned int));//4
    printf("short %d\n", sizeof(short));//2
    printf("unsigned short %d\n", sizeof(unsigned short));//2
    printf("long %d\n", sizeof(long));//8
    printf("unsigned long %d\n", sizeof(unsigned long));//8
    printf("long long %d\n", sizeof(long long));//8
    printf("unsigned long long %d\n", sizeof(unsigned long long));//8

    int val1 = 100;
    //-2,147,483,648~2,147,483,647(+0)
    int val2 = 2147483647;
    //4,294,967,296     4字节表示的数据范围大小 0~4,294,967,295
    unsigned int val3 = 4294967295;
    //-32768~32767
    short val4 = 32767;
    //0~65535
    unsigned short val5 = 65535;
    //-9,223,372,036,854,775,808~9,223,372,036,854,775,807
    long val6 = 9223372036854775807;
    //0~18,446,744,073,709,551,615
    unsigned long val7 = 18446744073709551615;
    //-9,223,372,036,854,775,808~9,223,372,036,854,775,807
    long long val8 = 9223372036854775807;
    //0~18,446,744,073,709,551,615
    unsigned long long val9 = 18446744073709551615;
    PRINT_VAR1(val1);
    PRINT_VAR1(val2 + 1);

    PRINT_VAR2(val3);// unsigned int 类型的打印要用%u
    PRINT_VAR2(val3 + 1);

    printf("val4 = %hd\n", val4);
    printf("val4+5 = %hd\n", val4 + 5);

    printf("val5 = %hu\n", val5);
    printf("val5+5 = %hu\n", val5 + 5);

    printf("val6 = %ld\n", val6);//val6 = 9223372036854775807
    printf("val6+1 = %ld\n", val6 + 1);//val6+1 = -9223372036854775808

    printf("val7 = %lu\n", val7);//val7 = 18446744073709551615
    printf("val7+1 = %lu\n", val7 + 1);//val7+1 = 0

    printf("val8 = %lld\n", val8);//val8 = 9223372036854775807
    printf("val8+1 = %lld\n", val8 + 1);//val8+1 = -9223372036854775808

    printf("val9 = %llu\n", val9);//val9 = 18446744073709551615
    printf("val9+1 = %llu\n", val9 + 1);//val9+1 = 0

    system("read -rsp $'Press enter to continue...\\n'");
    return EXIT_SUCCESS;
}